package com.lee.dutylower.view;

import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.lee.dutylower.R;
import com.lee.dutylower.db.BaseDB;


/**
 * Created by lijie on 2017/5/2.
 */

public class BaseFragment extends Fragment {
    public FragmentManager mFragmentManager;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mFragmentManager = getActivity().getFragmentManager();
    }

    public void addFragment(Fragment fragment, BaseDB baseDB, String key){
        Bundle b = new Bundle();
        b.putSerializable(key,baseDB);
        fragment.setArguments(b);
        mFragmentManager.beginTransaction().replace(R.id.ll_setting_detail,fragment).commit();
    }
    public void addEditFragment(Fragment fragment, BaseDB baseDB, String key){
        Bundle b = new Bundle();
        b.putSerializable(key,baseDB);
        b.putBoolean("isEditable",true);
        fragment.setArguments(b);

        mFragmentManager.beginTransaction().replace(R.id.ll_setting_detail,fragment).commit();
    }

    public void addEmptyFragment(Fragment fragment){
        mFragmentManager.beginTransaction().replace(R.id.ll_setting_detail,fragment).commit();
    }
}
